Read the data.

Check for Missing Values

Fill Missing Values by Interpolation

Plot the Time Series

Check the basic measures of descriptive statistics of the Time Series

Plot Box-plot Monthwise

Decompose the Time Series and plot the different components.

Additive Decomposition of Rose

Additive Decomposition of Sparkling

Multiplicative Decomposition of Rose

For the multiplicative series, we see that a lot of residuals are located around 1.

Multiplicative Decomposition of Sparkling

Split the data into train and test and plot the training and test data. [Test Data should start from 1991]

Building different models and comparing the accuracy metrics.

Model 1: Linear Regression on Rose

For this particular linear regression, we are going to regress the 'Rose' variable against the order of the occurrence. For this we need to modify our training data before fitting it into a linear regression.

We see that we have successfully the generated the numerical time instance order for both the training and test set. Now we will add these values in the training and test set.

Now that our training and test data has been modified, let us go ahead use $\underline{Linear Regression}$ to build the model on the training data and test the model on the test data.

Defining the functions for calculating the accuracy metrics.

Model Evaluation

Model 1: Linear Regression Sparkling

We see that we have successfully the generated the numerical time instance order for both the training and test set. Now we will add these values in the training and test set.

Now that our training and test data has been modified, let us go ahead use $\underline{Linear Regression}$ to build the model on the training data and test the model on the test data.

Defining the functions for calculating the accuracy metrics.

Model Evaluation

Model 2: Naive Approach Rose : $\hat{y}_{t+1} = y_t$

For this particular naive model, we say that the prediction for tomorrow is the same as today and the prediction for day after tomorrow is tomorrow and since the prediction of tomorrow is same as today,therefore the prediction for day after tomorrow is also today.

Model Evaluation

Model 2: Naive Approach Sparkling : $\hat{y}_{t+1} = y_t$

For this particular naive model, we say that the prediction for tomorrow is the same as today and the prediction for day after tomorrow is tomorrow and since the prediction of tomorrow is same as today,therefore the prediction for day after tomorrow is also today.

Model Evaluation

Model 3: Simple Average Rose

For this particular simple average method, we will forecast by using the average of the training values.

Model Evaluation

Model 3: Simple Average Sparkling

For this particular simple average method, we will forecast by using the average of the training values.

Model Evaluation

Model 4: Moving Average(MA) - Rose

For the moving average model, we are going to calculate rolling means (or moving averages) for different intervals. The best interval can be determined by the maximum accuracy (or the minimum error) over here.

For Moving Average, we are going to average over the entire data.

Trailing moving averages

Let us split the data into train and test and plot this Time Series. The window of the moving average is need to be carefully selected as too big a window will result in not having any test set as the whole series might get averaged over.

Model Evaluation

Done only on the test data.

Method 4: Moving Average(MA) - Sparkling

Trailing moving averages

Let us split the data into train and test and plot this Time Series. The window of the moving average is need to be carefully selected as too big a window will result in not having any test set as the whole series might get averaged over.

Model Evaluation

Done only on the test data.

Consolidated plots of All Models- Rose

Consolidated plots of All Models- Sparkling

Simple Exponential Smoothing, Holt's Model (Double Exponential Smoothing) & Holt-Winter's Model (Triple Exponential Smoothing)

SES - ETS(A, N, N) - Simple Exponential Smoothing with additive errors - ROSE

SimpleExpSmoothing class must be instantiated and passed the training data.

The fit() function is then called providing the fit configuration, the alpha value, smoothing_level. If this is omitted or set to None, the model will automatically optimize the value.

Here, Python has optimized the smoothing level to be almost 0.1

SES - ETS(A, N, N) - Simple Exponential Smoothing with additive errors - SPARKLING

SimpleExpSmoothing class must be instantiated and passed the training data.

The fit() function is then called providing the fit configuration, the alpha value, smoothing_level. If this is omitted or set to None, the model will automatically optimize the value.

Holt - ETS(A, A, N) - Holt's linear method with additive errors - Rose

Double Exponential Smoothing - Rose

We see that the double exponential smoothing is picking up the trend component along with the level component as well.

Holt - ETS(A, A, N) - Holt's linear method with additive errors - Sparkling

Double Exponential Smoothing - Sparkling

Inference

Here, we see that the Double Exponential Smoothing has actually done well when compared to the Simple Exponential Smoothing. This is because of the fact that the Double Exponential Smoothing model has picked up the trend component as well.

Holt-Winters - ETS(A, A, A) - Holt Winter's linear method with additive errors - ROSE

We see that the Triple Exponential Smoothing is picking up the seasonal component as well.

Inference

Triple Exponential Smoothing has performed the best on the test as expected since the data had both trend and seasonality.

Holt-Winters - ETS(A, A, A) - Holt Winter's linear method with additive errors - SPARKLING

We see that the Triple Exponential Smoothing is picking up the seasonal component as well.

Holt-Winters - ETS(A, A, M) - Holt Winter's linear method - ROSE

ETS(A, A, M) model - Taking MULTIPLICATIVE SEASONALITY

Report model accuracy

We see that the multiplicative seasonality model has not done that well when compared to the additive seasonality Triple Exponential Smoothing model.

Holt-Winters - ETS(A, A, M) - Holt Winter's linear method - SPARKLING

ETS(A, A, M) model - Taking MULTIPLICATIVE SEASONALITY

Report model accuracy

Holt-Winters - ETS(A, Ad, A) - Holt Winter's linear method with additive errors - ROSE

USING DAMPED TREND

Holt-Winters - ETS(A, A, A) - Holt Winter's linear method with additive errors - SPARKLING

USING DAMPED TREND

Holt-Winters - ETS(A, A, M) - Holt Winter's linear method - ROSE

USING DAMPED TREND

ETS(A, Ad, M) model - Taking MULTIPLICATIVE SEASONALITY

Report model accuracy

Holt-Winters - ETS(A, A, M) - Holt Winter's linear method - SPARKLING

ETS(A, A, M) model - Taking MULTIPLICATIVE SEASONALITY

USING DAMPED TREND

Report model accuracy

Best Model for Rose till Now - 2 Pt Moving Average

Trailing moving averages

Holt-Winters - ETS(A, A, M) - Best Model for Sparkling Till Now

ETS(A, Ad, M) model - Taking MULTIPLICATIVE SEASONALITY

USING DAMPED TREND

==================================================================================================================

==================================================================================================================

Check Stationarity of ROSE Data

The Augmented Dickey-Fuller test is an unit root test which determines whether there is a unit root and subsequently whether the series is non-stationary.

The hypothesis in a simple form for the ADF test is:

We would want the series to be stationary for building ARIMA models and thus we would want the p-value of this test to be less than the $\alpha$ value.

We see that at 5% significant level the Time Series is non-stationary.

Let us take one level of differencing to see whether the series becomes stationary.

We see that p-value < alpha=0.05 Hence, we reject the Null Hypothesis

We conclude that with a lag 1 - now the Rose data is Stationary

Now, let us go ahead and plot the stationary series.

Check Stationarity of SPARKLING Data

The Augmented Dickey-Fuller test is an unit root test which determines whether there is a unit root and subsequently whether the series is non-stationary.

The hypothesis in a simple form for the ADF test is:

We would want the series to be stationary for building ARIMA models and thus we would want the p-value of this test to be less than the $\alpha$ value.

We see that at 5% significant level the Time Series is non-stationary.

Let us take one level of differencing to see whether the series becomes stationary.

We see that p-value < alpha=0.05 Hence, we reject the Null Hypothesis

We conclude that with a lag 1 - now the Sparkling data is Stationary

Now, let us go ahead and plot the stationary series.

ARIMA / SARIMA on ROSE

Check for Stationarity of Rose Train Data

Let us plot the training data once.

The training data is non-stationary at 95% confidence level. Let us take a first level of differencing to stationarize the Time Series.

p-value < 0.05 ------> So at 95% Confidence Interval. Train Rose data is Stationary with lag 1 Now, let us go ahead and plot the differenced training data.

Build an Automated version of an ARIMA model for which the best parameters are selected in accordance with the lowest Akaike Information Criteria (AIC).

Note: The data has some seasonality so ideally we should build a SARIMA model. But lets test on the lowest Akaike Information Criteria, which one suits best - ARIMA or SARIMA

Rose Train Diagnostics plot.

Predict on the Rose Test Set using this model and evaluate the model.

Build a version of the ARIMA model for which the best parameters are selected by looking at the ACF and the PACF plots on ROSE dataset

Let us look at the ACF and the PACF plots once more.

Here, we have taken alpha=0.05.

By looking at the above plots, we will take the value of p and q to be 2 and 2 respectively.

Let us analyse the residuals from the various diagnostics plot.

Predict on the Test Set using this model and evaluate the model.

Build an Automated version of a SARIMA model for which the best parameters are selected in accordance with the lowest Akaike Information Criteria (AIC) - ROSE DATA

Let us look at the ACF plot once more to understand the seasonal parameter for the SARIMA model.

We can see that there is a seasonality.

Predict on the Test Set using this model and evaluate the model.

Build a version of the SARIMA model for which the best parameters are selected by looking at the ACF and the PACF plots. - Seasonality at 12

Let us look at the ACF and the PACF plots once more.

Here, we have taken alpha=0.05.

We are going to take the seasonal period as 12 We are taking the p value to be 2 and the q value also to be 2 as the parameters same as the ARIMA model.

Predict on the Test Set using this model and evaluate the model.

Building the most optimum model on the Full Data.

Here, we have a scenario where our training data was stationary but our full data was not stationary. So, we will use the same parameters as our training data but with adding a level of differencing which is needed for the data to be stationary.

Evaluate the model on the whole data and predict 12 months into the future

=================================================================

ARIMA / SARIMA Modelling on SPARKLING dataset

Check for stationarity of the Training Data - Sparkling

Let us plot the training data once.

The training data is non-stationary at 95% confidence level. Let us take a first level of differencing to stationarize the Time Series.

Training data is now Stationary Now, let us go ahead and plot the differenced training data.

Build an Automated version of an ARIMA model for which the best parameters are selected in accordance with the lowest Akaike Information Criteria (AIC) - SPARKLING

Note: The data has some seasonality so ideally we should build a SARIMA model. But we'll check least AIC of ARIMA and then SARIMA

Diagnostics plot - Sparkling

Predict on the Test Set using this model and evaluate the model.

Build a version of the ARIMA model for which the best parameters are selected by looking at the ACF and the PACF plots - SPARKLING

Let us look at the ACF and the PACF plots once more.

By looking at the above plots, we will take the value of p and q to be 0 and 0 respectively.

Let us analyse the residuals from the various diagnostics plot.

Predict on the Test Set using this model and evaluate the model.

Build an Automated version of a SARIMA model for which the best parameters are selected in accordance with the lowest Akaike Information Criteria (AIC) - SPARKLING

Let us look at the ACF plot once more to understand the seasonal parameter for the SARIMA model.

We can see that there is a seasonality.

Predict on the Test Set using this model and evaluate the model.

Build a version of the SARIMA model for which the best parameters are selected by looking at the ACF and the PACF plots. - Seasonality at 12 - SPARKLING

Let us look at the ACF and the PACF plots once more.

Predict on the Test Set using this model and evaluate the model.

Building the most optimum model on the Full Data.

Here, we have a scenario where our training data was stationary but our full data was not stationary. So, we will use the same parameters as our training data but with adding a level of differencing which is needed for the data to be stationary.

Evaluate the model on the whole data and predict 12 months into the future

=============================================================================================